package org.andromeo;

import java.util.Comparator;
import java.util.Date;

public abstract class User  {

	private String onlinestatus;
	private String userid;
	private String username;
	private String urlString;
	private String thumbnailImageURL;
	private String recFootprintURL;
	private String recFootprintTitle;
	private Date lastOnlineDate;
	
	public Date getLastOnlineDate() {
		return lastOnlineDate;
	}


	public void setLastOnlineDate(Date lastOnlineDate) {
		this.lastOnlineDate = lastOnlineDate;
	}


	public String getRecFootprintTitle() {
		return recFootprintTitle;
	}


	public void setRecFootprintTitle(String recFootprintTitle) {
		this.recFootprintTitle = recFootprintTitle;
	}


	private String givFootPrintURL;
	
	
	public String getThumbnailImageURL() {
		return thumbnailImageURL;
	}


	public void setThumbnailImageURL(String thumbnailImageURL) {
		this.thumbnailImageURL = thumbnailImageURL;
	}


	public String getRecFootprintURL() {
		return recFootprintURL;
	}


	public void setRecFootprintURL(String recFootprintURL) {
		this.recFootprintURL = recFootprintURL;
	}


	public String getGivFootPrintURL() {
		return givFootPrintURL;
	}


	public void setGivFootPrintURL(String givFootPrintURL) {
		this.givFootPrintURL = givFootPrintURL;
	}




	public User(String uid) {
		this.setUserID(uid);
	}

	
	public String getOnlineStatus() {
		// TODO Auto-generated method stub
		return onlinestatus;
	}


	public String getUserID() {
		// TODO Auto-generated method stub
		return userid;
	}


	public String getUserName() {
		// TODO Auto-generated method stub
		return username;
	}


	public void setOnlineStatus(String status) {
		// TODO Auto-generated method stub
		this.onlinestatus = status;
	}


	public void setUserID(String userid) {
		// TODO Auto-generated method stub
		this.userid = userid;
	}


	public void setUserName(String name) {
		// TODO Auto-generated method stub
		this.username = name;
	}


	public String toString() {
		// TODO Auto-generated method stub
		String zeile = "";
		if (getUserName()!=null)
			zeile = zeile.concat(getUserName());
		zeile = zeile.concat(" - ");
		if (getOnlineStatus()!=null)
			zeile = zeile.concat(getOnlineStatus());
		zeile = zeile.concat(" - ");

		return zeile;
	}


	public String getProfileURL() {
		return this.urlString;
	}


	public void setProfileURL(String urlString) {
		this.urlString = urlString;
	}

	
	public static Comparator<User> getCompSortByIdDescending() {
		return new Comparator<User>() {

			@Override
			public int compare(User object1, User object2) {

				long i1 = 0;
				long i2 = 0;
				try {
					i1 = Long.valueOf(object1.getUserID());
					i2 = Long.valueOf(object2.getUserID());
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				if (i1 < i2)
					return 1;
				else if (i1 > i2)
					return -1;
				else
					return 0;
			};

		};
	}
	
	public static final Comparator<User> getCompSortByLastOnline() {
		return new Comparator<User>() {

			@Override
			public int compare(User object1, User object2) {

				Date i1 = new Date();
				Date i2 = new Date();
				
				if (object1.getLastOnlineDate()!=null)
					i1 = object1.getLastOnlineDate();

				if (object2.getLastOnlineDate()!=null)
					i2 = object2.getLastOnlineDate();
				
				// descending order
				return -1 * i1.compareTo(i2);
			};

		};
	}
	
}